package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo02 {

	public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchFieldException {
		//Class�����
		Class clazz=Class.forName("reflect.Person");
//		Object o=clazz.newInstance();
		Constructor c=clazz.getDeclaredConstructor(String.class,int.class);
		c.setAccessible(true);
		Object o=c.newInstance("zhangyi",44);
//		System.out.println(o);
//		Method[] method=clazz.getMethods();
//		Method[] method=clazz.getDeclaredMethods();
//		for(Method m:method){
//			System.out.println(m);
//		}
//		Method m=clazz.getDeclaredMethod("display");
//		m.invoke(o);
		
		/*Method m=clazz.getDeclaredMethod("show",String.class,int.class);
		m.setAccessible(true);
		m.invoke(o, "hello",90);*/
		Field f=clazz.getDeclaredField("name");
		f.setAccessible(true);
		f.set(o, "wanger");
		System.out.println(o);
	}

}
/*
���췽����Construtor
������Method  m.invoke(object,paramlist);
���ԣ�

spring ��� ioc ���Ʒ�ת


*/